package Dao;

import static org.junit.Assert.*;

import java.util.ArrayList;
import java.util.List;

import org.junit.Before;
import org.junit.Test;

import Entity.CourseResource;
import junit.framework.Assert;

public class CourseResourceDaoTest {
	List<CourseResource> crlist=new ArrayList<CourseResource>();
	CourseResource cr=new CourseResource("201300042019061112","jsp","jsp教学大纲.docx","20130004","20190611",
			"D:\\eclipseJavaEE-workspace\\.metadata\\.plugins\\org.eclipse.wst.server.core\\tmp0\\wtpwebapps\\UniversityResourceSystem\\20130004/jsp教学大纲.docx", 
			"这是jsp教学大纲。");
	CourseResourceDao crd=new CourseResourceDao();

	@Before
	public void setUp() throws Exception {
	}

	@Test
	public void testAddCourseResource() {
		assertEquals(1,crd.addCourseResource(cr));
	}

	@Test
	public void testDeleteCourseResourceById() {
		assertEquals(1,crd.deleteCourseResourceById("201300072019061124"));
	}

	@Test
	public void testQueryCourseResourceByCourseID() {
		assertEquals("2013000120190617130",crd.queryCourseResourceByCourseID("2013000120190617130").courseID);
	}

	@Test
	public void testQueryCourseResourceByLabel() {
		crlist=crd.queryCourseResourceByLabel("oracle");
		for(int i=0;i<crlist.size();i++) {
		assertEquals("oracle",crlist.get(i).label);
		}
	}

	@Test
	public void testQueryCourseResourceByUploaderID() {
		crlist=crd.queryCourseResourceByUploaderID("20130001");
		for(int i=0;i<crlist.size();i++) {
			assertEquals("20130001",crlist.get(i).uploaderID);
		}
	}

	@Test
	public void testShowAllCourses() {
		crlist=crd.showAllCourses();
		Assert.assertNotNull(crlist);
	}

	@Test
	public void testQueryRecordCount() {
		assertEquals(36,crd.queryRecordCount());
	}

}
